textview: fix bug on DnD displaced limits of selection
authorNelson Benítez León <nbenitezl+gnome@gmail.com>
Wed, 2 Aug 2017 14:03:28 +0000 (19:03 +0500)
committerDaniel Boles <dboles@src.gnome.org>
Tue, 29 Aug 2017 18:26:07 +0000 (19:26 +0100)
The fix of commit f2fd655754407103f8fb9b2c3e7586fb595ab917
should be confined to DnD coords only, because otherwise
it causes the start and end of the selection to be displaced.

https://bugzilla.gnome.org/show_bug.cgi?id=785736

gtk/gtktextview.c

index e624d2703dc78fa3e696fa9e336dd5df2d7e681b..0b8197560687e2643820053ba03ca12ed721ea59 100644 (file)
@@ -8265,9 +8265,6 @@ gtk_text_view_drag_motion (GtkWidget        *widget,
       y > (target_rect.y + target_rect.height))
     return FALSE; /* outside the text window, allow parent widgets to handle event */
 
-  x -= target_rect.x;
-  y -= target_rect.y;
-
   gtk_text_view_window_to_buffer_coords (text_view,
                                          GTK_TEXT_WINDOW_WIDGET,
                                          x, y,
@@ -8327,8 +8324,11 @@ gtk_text_view_drag_motion (GtkWidget        *widget,
       gtk_text_mark_set_visible (priv->dnd_mark, FALSE);
     }
 
-  priv->dnd_x = x;
-  priv->dnd_y = y;
+  /* DnD uses text window coords, so subtract extra widget
+   * coords that happen e.g. when displaying line numbers.
+   */
+  priv->dnd_x = x - target_rect.x;
+  priv->dnd_y = y - target_rect.y;
 
   if (!priv->scroll_timeout)
   {